/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { BaseMatcher } from '../BaseMatcher.js';
/**
 * Is the value the same object as another value?
 */
export class IsSame extends BaseMatcher {
    constructor(object) {
        super();
        this.object = object;
    }
    matches(arg) {
        return arg === this.object;
    }
    describeTo(description) {
        description.appendText("sameInstance(")
            .appendValue(this.object)
            .appendText(")");
    }
    /**
     * Creates a matcher that matches only when the examined object is the same instance as
     * the specified target object.
     *
     * @param <T>
     *     the matcher type.
     * @param target
     *     the target instance against which others should be assessed
     * @return The matcher.
     */
    static sameInstance(target) {
        return new IsSame(target);
    }
    /**
     * Creates a matcher that matches only when the examined object is the same instance as
     * the specified target object.
     *
     * @param <T>
     *     the matcher type.
     * @param target
     *     the target instance against which others should be assessed
     * @return The matcher.
     */
    static theInstance(target) {
        return new IsSame(target);
    }
}
